package com.itguigu.controller;

import com.itguigu.pojo.Type;
import com.itguigu.pojo.vo.PortalVo;
import com.itguigu.service.HeadlineService;
import com.itguigu.service.TypeService;
import com.itguigu.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *  首页controller
 */


@RestController
@RequestMapping("portal")
@CrossOrigin
public class PortalController {


    @Autowired
    private TypeService typeService;

    @Autowired
    private HeadlineService headlineService;

    /**
     * 获取新闻栏目
     * @return
     */
    @GetMapping("findAllTypes")
    public Result getAllTypes(){

        List<Type> typeList = typeService.list();
        return Result.ok(typeList);

    }

    @PostMapping("findNewsPage")
    public Result findNewsPage(@RequestBody PortalVo portalVo){

       Result result =  headlineService.findNewsPage(portalVo);
       return result;


    }

    @PostMapping("showHeadlineDetail")
    public Result showHeadlineDetail(@RequestParam Long hid){


        Result result = headlineService.ContextInfomation(hid);

        return  result;

    }




}
